package 线程.练习;

public class ticket extends Thread {
    private static int nums = 100;

    @Override
    public void run() {
       while (true){
           if(nums <= 0){
               System.out.println("窗口"+Thread.currentThread().getName()+"票已经售完");
               break;
           }
           try {
               Thread.sleep(80);
           } catch (InterruptedException e) {
               e.printStackTrace();
           }
           System.out.println("窗口 " + Thread.currentThread().getName()+"卖了一张票"
           +"\t剩余 "+--nums+"张票");
       }
    }
}
class test{
    public static void main(String[] args) {
        ticket t1 = new ticket();
        ticket t2 = new ticket();
        ticket t3 = new ticket();

        t1.start();
        t2.start();
        t3.start();
    }
}
